import Cookies from 'js-cookie'
const getters = {
  sessionId: state => {
    let userInfo = state.user.userInfo
    if (!userInfo) {
      userInfo = JSON.parse(Cookies.get('userInfo'))
    }
    if (userInfo) {
      return userInfo.sessionId
    }
    return null
  },
  userInfo: state => {
    let userInfo = state.user.userInfo
    if (!userInfo) {
      // userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
      userInfo = JSON.parse(Cookies.get('userInfo'))
    }
    return userInfo
  },
  role: state => state.user.role,
  passwordFlag: state => state.user.passwordFlag,
  roleInfo: state => state.user.roleInfo,
  roleList: state => state.user.roleList,
  isSetRoutes: state => state.user.isSetRoutes,
  visitedViews: state => state.tagsView.visitedViews,
  cachedViews: state => state.tagsView.cachedViews,
  permission_routes: state => state.permission.routes
}
export default getters
